//
//  HDFontHeightTest.m
//  HDCommon
//
//  Created by Huadong Zheng on 2023/4/12.
//

#import "HDFontHeightTest.h"

@implementation HDFontHeightTest
// 字体缩放后，高度几乎是按照比例缩放的， 宽度上，只有英文的时候有可能变短一点点，效果也不太明显，测试一下, 满屏的时候会有20pt左右的偏差，这里因为中英文不一样，所以没办法适配，如果碰到一些特殊情况要考虑一下
// 测试结果sizetofit之后行高是基本符合标准的，但是蓝湖的控件行高和字体的行高不一致造成的，其实也有办法，直接按照蓝湖给的控件高度设置高度（等比缩放，因为字体缩放高度比例和字体等比缩放的比例几乎一样）
// 最后总结：
// 如果遇到单行的情况， 直接设置蓝湖的控件高度，如果遇到多行的情况 就直接使用sizetofit；
//
+(void) printFontAndFontHeight{
    
//    uif
//    UIFont * font = [UIFont f]
    
    UILabel * elb = [[UILabel alloc] init];
    UILabel * zLb = [[UILabel alloc] init];
    elb.text = @"englishenglishenglishenglishenglishenglishenglishen";
    zLb.text = @"中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文中文";
    
    
    NSArray * lanhuFontArray = @[
        @{@"weight":@(UIFontWeightRegular),@"font":@(15),@"height":@(17.58),@"runHeight":@(18)},
        @{@"weight":@(UIFontWeightRegular),@"font":@(14),@"height":@(16.41), @"runHeight":@(17)},
        @{@"weight":@(UIFontWeightRegular),@"font":@(14),@"height":@(16.41), @"runHeight":@(17)},
        @{@"weight":@(UIFontWeightRegular),@"font":@(10),@"height":@(11.72), @"runHeight":@(12)},
    ];
    
    CGFloat pingmukuandu = 1.32;
    
    
    
    for (NSInteger i = 5; i < 30; i += 1) {
        
        elb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightLight)];
        zLb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightLight)];
        [elb sizeToFit];
        [zLb sizeToFit];
        
        
        CGFloat originEWidth = elb.frame.size.width;
        CGFloat originEHeight = elb.frame.size.height;
        
        CGFloat originZWidth = zLb.frame.size.width;
        CGFloat originZHeight = zLb.frame.size.height;
        
        
        elb.font = [UIFont systemFontOfSize:i * pingmukuandu weight:(UIFontWeightLight)];
        zLb.font = [UIFont systemFontOfSize:i * pingmukuandu weight:(UIFontWeightLight)];
        [elb sizeToFit];
        [zLb sizeToFit];
        
        
        CGFloat toriginEWidth = elb.frame.size.width;
        CGFloat toriginEHeight = elb.frame.size.height;
        
        CGFloat toriginZWidth = zLb.frame.size.width;
        CGFloat toriginZHeight = zLb.frame.size.height;
        
        NSLog(@"UIFontWeightLight font:%ld : elbWidth %@, zlbSize %@",i ,sizeString(elb.frame.size), sizeString(zLb.frame.size));
        
        
        NSLog(@"font %ld 比例： %.2lf width e比例：%.2lf, width和等比例相差: %.2lf z比例：%.2lf, 中文width和等比例相差: %.2lf  height e比例：%.2lf, z比例：%.2lf ",i,pingmukuandu,toriginEWidth/originEWidth , toriginEWidth - originEWidth * pingmukuandu,toriginZWidth/originZWidth, toriginZWidth - originZWidth * pingmukuandu, toriginEHeight/ originEHeight, toriginZHeight / originZHeight);
        
        
        
//        elb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightRegular)];
//        zLb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightRegular)];
//        [elb sizeToFit];
//        [zLb sizeToFit];
//        NSLog(@"UIFontWeightRegular font:%ld : elbWidth %@, zlbSize %@",i ,sizeString(elb.frame.size), sizeString(zLb.frame.size));
        
//
//        elb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightMedium)];
//        zLb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightMedium)];
//        [elb sizeToFit];
//        [zLb sizeToFit];
//        NSLog(@"UIFontWeightMedium font:%ld : elbWidth %@, zlbSize %@",i ,sizeString(elb.frame.size), sizeString(zLb.frame.size));
//
//
//
//        elb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightSemibold)];
//        zLb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightSemibold)];
//        [elb sizeToFit];
//        [zLb sizeToFit];
//        NSLog(@"UIFontWeightSemibold font:%ld : elbWidth %@, zlbSize %@",i ,sizeString(elb.frame.size), sizeString(zLb.frame.size));
        
        
        
//        elb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightHeavy)];
//        zLb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightHeavy)];
//        [elb sizeToFit];
//        [zLb sizeToFit];
//        NSLog(@"UIFontWeightHeavy font:%ld : elbWidth %@, zlbSize %@",i ,sizeString(elb.frame.size), sizeString(zLb.frame.size));
//
//
//        elb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightBlack)];
//        zLb.font = [UIFont systemFontOfSize:i weight:(UIFontWeightBlack)];
//        [elb sizeToFit];
//        [zLb sizeToFit];
//        NSLog(@"UIFontWeightBlack font:%ld : elbWidth %@, zlbSize %@",i ,sizeString(elb.frame.size), sizeString(zLb.frame.size));
        
    }
    
    
//    UIFont * font
    
}


static NSString * sizeString(CGSize size){
    
    return [NSString stringWithFormat:@"{%.2lf , %.2lf}",size.width, size.height];
    
}

@end
